<script src="<?php echo base_url() ?>commons/validacion/js/jquery-1.8.2.min.js" type="text/javascript"></script>
<link href="<?php echo base_url() ?>commons/validacion/css/validationEngine.jquery.css" rel="stylesheet">
<script src="<?php echo base_url() ?>commons/validacion/js/languages/jquery.validationEngine-es.js" type="text/javascript" charset="utf-8"></script>
<script src="<?php echo base_url() ?>commons/validacion/js/jquery.validationEngine.js" type="text/javascript" charset="utf-8"></script>



<script>
    var t = jQuery.noConflict();
    t(document).ready(function() {
        // binds form submission and fields to the validation engine			
        t("#formID").validationEngine();
         t("#formID1").validationEngine();
         t("#formID2").validationEngine();
    });

    /**
     *
     * @param {jqObject} the field where the validation applies
     * @param {Array[String]} validation rules for this field
     * @param {int} rule index
     * @param {Map} form options
     * @return an error string if validation failed
     */
    function checkHELLO(field, rules, i, options) {
        if (field.val() != "HELLO") {
            // this allows to use i18 for the error msgs
            return options.allrules.validate2fields.alertText;
        }
    }
</script>
<link rel="stylesheet" href="<? echo base_url() ?>commons/jquery/themes/base/jquery.ui.all.css">

<script src="<?php echo base_url() ?>commons/jquery/ui/jquery.ui.core.js"></script>
<script src="<?php echo base_url() ?>commons/jquery/ui/jquery.ui.widget.js"></script>
<script src="<?php echo base_url() ?>commons/jquery/ui/jquery.ui.tabs.js"></script>

<!--
<script src="<?php echo base_url() ?>commons/jquery/external/jquery.mousewheel.js"></script>
<script src="<?php echo base_url() ?>commons/jquery/external/globalize.js"></script>
<script src="<?php echo base_url() ?>commons/jquery/external/globalize.culture.de-DE.js"></script>
<script src="<?php echo base_url() ?>commons/jquery/external/globalize.culture.ja-JP.js"></script>
<script src="<?php echo base_url() ?>commons/jquery/ui/jquery.ui.core.js"></script>
<script src="<?php echo base_url() ?>commons/jquery/ui/jquery.ui.widget.js"></script>
<script src="<?php echo base_url() ?>commons/jquery/ui/jquery.ui.button.js"></script>
<script src="<?php echo base_url() ?>commons/jquery/ui/jquery.ui.spinner.js"></script>
<link rel="stylesheet" href="<? echo base_url() ?>commons/jquery/demos/demos.css">
<link rel="stylesheet" href="<? echo base_url() ?>commons/jquery/themes/base/jquery.ui.all.css">
<script>
    var t1 = jQuery.noConflict();
        t1(function() {
                        
                t1( "#1_ec1" ).spinner({
                        step: 0.01,
                        numberFormat: "n"
                });

                
        });
        </script>
-->
<script>
    var t1 = jQuery.noConflict();
    t1(function() {
        t1("#tabs").tabs();
    });
</script>
</br>
<?php
    echo '<div>';
    
        echo '<p style="text-align: center;font-weight: bold;"><span>PERIODO '.$periodo[0]["descripcion_lec"].'</span></p>';        
        echo '<p><span><b>CARRERA:</b> '.$carrera.'</span></p>';
        echo '<p><span><b>CICLO:</b> '.$ciclo.'</span></p>';
        echo '<p><span><b>MATERÍA:</b> '.$materia.'</span></p>';
        echo '<p><span><b>PARALELO:</b> '.$paralelo.'</span></p>';
        echo '<p><span><b>SECCIÓN:</b> '.$seccion.'</span></p>';
    echo '</div>';
?>
<?php
        $CI = & get_instance();
        echo '<script type="text/javascript">';
        echo 'var t = jQuery.noConflict(); ';
        echo 't(document).ready(function(){
				       setTimeout(function(){ t(".mensajes").fadeOut(800).fadeIn(800).fadeOut(500).fadeIn(500).fadeOut(300);}, 3000); ';
        echo '		});';
        echo '</script>';
        echo validation_errors('<div class="error">', '</div>');
        if ($this->session->flashdata('error')) {
            echo "<div class='error mensajes'>";
            echo $this->session->flashdata('error');
            echo "</div>";
        }
        if ($this->session->flashdata('info')) {
            echo "<div class='info mensajes'>";
            echo $this->session->flashdata('info');
            echo "</div>";
        }
        //alerta
        if ($this->session->flashdata('exito')) {
            echo "<div class='info mensajes'>";
            echo $this->session->flashdata('exito');
            echo "</div>";
        }
        if ($this->session->flashdata('alerta')) {
            echo "<div class='info mensajes'>";
            echo $this->session->flashdata('alerta');
            echo "</div>";
        }
        if (count($listaEstudiante) > 0) {
            $aux = 'return confirm("Esta seguro de realizar esta operación");';
            echo "<a href='" . base_url() . "docente.php/docente/volveCrearListaAlumno" . $link . "' class='btn' onclick='" . $aux . "'>VOLVER A GENERAR LISTADO</a>";
        }
            
        ?>
</br>

</br>
<div id="tabs" >
    <ul>
        <li><a href="#tabs-1">Primer Bimestre</a></li>
        <li><a href="#tabs-2">Segundo Bimestre</a></li>
        <li><a href="#tabs-3">Supletorios</a></li>
        <li><a href="#tabs-4">Cuadro Final de Calificaciones</a></li>
    </ul>
    <div id="tabs-1">
        <?php
        if (count($listaEstudiante) == 0) {

            $aux = 'return confirm("Advertencia: Si crea la lista de estudiantes ya no podrá volverla a generar. Está seguro de hacer esta operación");';
            echo '<div>';
            echo "<a href='" . base_url() . "docente.php/docente/crearListaAlumno" . $link . "' class='btn' onclick='" . $aux . "'>CREAR LISTADO ESTUDIANTES</a>";
            echo '</div>';
        } else {
            
            ?>
        
         <script>
                            function sumar(n, m, r){
                                r.value=(n.value*1)+(m.value*1);
                                r.value = Math.round(r.value);
                            }
                         </script>
        <form id="formID" method="post" action="<?php echo base_url()?>docente.php/docente/guardarCalificaciones<?php echo $link?>/1" onsubmit="return confirm('Está seguro de registrar las notas de primer bimestre')">
            <input value="REGISTRAR NOTAS" class="btn" type="submit"/>
                <table class="table table-bordered table-striped tablaVista">
                    <caption><h3>LISTADO DE ESTUDIANTES</h3></caption>
                    <thead>
                        <tr>
                            <th>Nro</th>
                            <th>APELLIDOS Y NOMBRES</th>
                            <th>EVALUACIÓN CONTINUA</th>
                            <th>EXAMEN BIMESTRAL</th>
                            <th>TOTAL</th>
                            <th>ASISTENCIA</th>
                            <th>OBSERVACIÓN</th>                
                        </tr>
                    </thead>
                    <tbody>
                        
                        <?php
                        $cont = 1;
                        foreach ($listaEstudiante as $i => $row) {
                            ?>
                            <tr>
                                <td><?php echo $cont ?></td>
                                <td><?php echo $row['apellido_pers'] . ' ' . $row['nombre_pers'] ?></td>
                                <td><input  value="<?php echo $row['evacont1_cal'] ?>" style="width: 40px;" name="<?php echo $row['ide_cal'] ?>_ec1" id="<?php echo $row['ide_cal'] ?>_ec1"  class="validate[required,maxSize[5],minSize[1],custom[number],min[0],max[12]]" onkeyup="sumar(document.getElementById('<?php echo $row['ide_cal'] ?>_ec1'), document.getElementById('<?php echo $row['ide_cal'] ?>_eb1'), document.getElementById('<?php echo $row['ide_cal'] ?>_to1'))"/></td>
                                <td><input  value="<?php echo $row['exam1_cal'] ?>" style="width: 40px;" name="<?php echo $row['ide_cal'] ?>_eb1" id="<?php echo $row['ide_cal'] ?>_eb1"  class="validate[required,maxSize[5],minSize[1],custom[number],min[0],max[8]]" onkeyup="sumar(document.getElementById('<?php echo $row['ide_cal'] ?>_ec1'), document.getElementById('<?php echo $row['ide_cal'] ?>_eb1'), document.getElementById('<?php echo $row['ide_cal'] ?>_to1'))"/></td>
                                <td><input  readonly="true" value="<?php echo $row['total1'] ?>" style="width: 40px;" name="<?php echo $row['ide_cal'] ?>_to1" id="<?php echo $row['ide_cal'] ?>_to1"  class="validate[required,maxSize[5],minSize[1],custom[number],min[0],max[20]]"/></td>
                                <td><input  value="<?php echo $row['asiste1_cal'] ?>" style="width: 40px;" name="<?php echo $row['ide_cal'] ?>_as1" id="<?php echo $row['ide_cal'] ?>_as1"  class="validate[required,maxSize[5],minSize[1],custom[number],min[0],max[100]]"/></td>                                
                                <td><textarea  name="<?php echo $row['ide_cal'] ?>_ob1" id="<?php echo $row['ide_cal'] ?>_ob1"  class="validate[maxSize[100],minSize[1]]"><?php echo $row['obs1_cal'] ?></textarea></td>
                                
                            </tr>

                            <?php
                            $cont++;
                        }
                        ?>
                    </tbody>
                </table>        
            <input value="REGISTRAR NOTAS" class="btn" type="submit"/>
                <?php
            }
            ?>
            
        </form>
    </div>
    
    <div id="tabs-2">
        <?php
        if (count($listaEstudiante) == 0) {

            //$aux = 'return confirm("Advertencia: Si crea la lista de estudiantes ya no podrá volverla a generar. Está seguro de hacer esta operación");';
            //echo "<a href='" . base_url() . "docente.php/docente/crearListaAlumno" . $link . "' class='btn' onclick='" . $aux . "'>CREAR LISTADO ESTUDIANTES</a>";
        } else {
            ?>
        <form id="formID1" method="post" action="<?php echo base_url()?>docente.php/docente/guardarCalificaciones<?php echo $link?>/2" onsubmit="return confirm('Está seguro de registrar las notas de segundo bimestre')">
                <input value="REGISTRAR NOTAS" class="btn" type="submit"/>
                <table class="table table-bordered table-striped tablaVista">
                    <caption><h3>LISTADO DE ESTUDIANTES</h3></caption>
                    <thead>
                        <tr>
                            <th>Nro</th>
                            <th>APELLIDOS Y NOMBRES</th>
                            <th>EVALUACIÓN CONTINUA</th>
                            <th>EXAMEN BIMESTRAL</th>
                            <th>TOTAL</th>
                            <th>ASISTENCIA</th>
                            <th>OBSERVACIÓN</th>                     
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        $cont = 1;
                        foreach ($listaEstudiante as $i => $row) {
                            ?>
                            <tr>
                                <td><?php echo $cont ?></td>
                                <td><?php echo $row['apellido_pers'] . ' ' . $row['nombre_pers'] ?></td>
                                <td><input  value="<?php echo $row['evacont2_cal'] ?>" style="width: 40px;" name="<?php echo $row['ide_cal'] ?>_ec2" id="<?php echo $row['ide_cal'] ?>_ec2"  class="validate[required,maxSize[5],minSize[1],custom[number],min[0],max[12]]" onkeyup="sumar(document.getElementById('<?php echo $row['ide_cal'] ?>_ec2'), document.getElementById('<?php echo $row['ide_cal'] ?>_eb2'), document.getElementById('<?php echo $row['ide_cal'] ?>_to2'))"/></td>
                                <td><input  value="<?php echo $row['exam2_cal'] ?>" style="width: 40px;" name="<?php echo $row['ide_cal'] ?>_eb2" id="<?php echo $row['ide_cal'] ?>_eb2"  class="validate[required,maxSize[5],minSize[1],custom[number],min[0],max[8]]" onkeyup="sumar(document.getElementById('<?php echo $row['ide_cal'] ?>_ec2'), document.getElementById('<?php echo $row['ide_cal'] ?>_eb2'), document.getElementById('<?php echo $row['ide_cal'] ?>_to2'))"/></td>
                                <td><input  readonly="true" value="<?php echo $row['total2'] ?>" style="width: 40px;" name="<?php echo $row['ide_cal'] ?>_to2" id="<?php echo $row['ide_cal'] ?>_to2"  class="validate[required,maxSize[5],minSize[1],custom[number],min[0],max[20]]"/></td>
                                <td><input  value="<?php echo $row['asiste2_cal'] ?>" style="width: 40px;" name="<?php echo $row['ide_cal'] ?>_as2" id="<?php echo $row['ide_cal'] ?>_as2"  class="validate[required,maxSize[5],minSize[1],custom[number],min[0],max[100]]"/></td>
                                <td><textarea  name="<?php echo $row['ide_cal'] ?>_ob2"  id="<?php echo $row['ide_cal'] ?>_ob2"  class="validate[maxSize[100],minSize[1]]"><?php echo $row['obs2_cal'] ?></textarea></td>

                            </tr>

                            <?php
                            $cont++;
                        }
                        ?>
                    </tbody>
                </table>        
        
        <?php }  ?>
                </form>
        
        
           
    </div>
    <div id="tabs-3">
        <?php if($verSupletarios==false){ ?>
        <span>No se pueden ver supletorios</span>
        <?php } else{ ?>
             <form id="formID2" method="post" action="<?php echo base_url()?>docente.php/docente/guardarSupletorios<?php echo $link?>/2" onsubmit="return confirm('Está seguro de registrar supletorios')">
                <input value="REGISTRAR SUPLETORIOS" class="btn" type="submit"/>
                <table class="table table-bordered table-striped tablaVista">
                    <caption><h3>LISTADO DE ESTUDIANTES</h3></caption>
                    <thead>
                        <tr>
                            <th>Nro</th>
                            <th>APELLIDOS Y NOMBRES</th>
                            <th>EVALUACIÓN CONTINUA</th>                            
                            <th>OBSERVACIÓN</th>                
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        $cont = 1;
                        foreach ($listaEstudianteSupletorios as $i => $row) {
                            ?>
                            <tr>
                                <td><?php echo $cont ?></td>
                                <td><?php echo $row['apellido_pers'] . ' ' . $row['nombre_pers'] ?></td>
                                <td><input  value="<?php echo $row['suple_cal'] ?>" style="width: 40px;" name="<?php echo $row['ide_cal'] ?>_sup" id="<?php echo $row['ide_cal'] ?>_sup"  class="validate[required,maxSize[5],minSize[1],custom[number],min[0],max[20]]" /></td>                                
                                
                                <td><textarea  name="<?php echo $row['ide_cal'] ?>_ob3"  id="<?php echo $row['ide_cal'] ?>_ob3"  class="validate[maxSize[100],minSize[1]]"><?php echo $row['obs3_cal'] ?></textarea></td>

                            </tr>

                            <?php
                            $cont++;
                        }
                        ?>
                    </tbody>
                </table>        
                <?php
            }
            ?>
        </form>
    </div>
    
     <div id="tabs-4">
        <?php if($verSupletarios==false){ ?>
        <span>No se pueden ver el cuadro de calificaciones</span>
        <?php } else{ ?>
             <form id="formID2" method="post" action="<?php echo base_url()?>docente.php/docente/guardarSupletorios<?php echo $link?>/2" onsubmit="return confirm('Está seguro de enviar el cuador de calificaciones')">
                <input value="ENVIAR CUADRO DE CALIFICACIONES" class="btn" type="submit"/>
                <table class="table table-bordered table-striped tablaVista">
                    <caption><h3>LISTADO DE ESTUDIANTES</h3></caption>
                    <thead>
                        <tr>
                            <th>Nro</th>
                            <th>APELLIDOS Y NOMBRES</th>
                            <th>NOTA PRIMER BIMESTRE</th>                            
                            <th>ASISTENCIA PRIMER BIMESTRE</th>                            
                            <th>NOTA SEGUNDO BIMESTRE</th>                            
                            <th>ASISTENCIA SEGUNDO BIMESTRE</th>                            
                            <th>TOTAL NOTAS</th>                            
                            <th>PROMEDIO ASISTENCIA</th>                            
                            <th>CONDICIÓN DEL ESTUDIANTE</th>                            
                            <th>OBSERVACIÓN</th>                
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        $cont = 1;
                        foreach ($listaResumen as $i => $row) {
                            ?>
                            <tr>
                                <td><?php echo $cont ?></td>
                                <td><?php echo $row['apellido_pers'] . ' ' . $row['nombre_pers'] ?></td>
                                <td><span><?php echo $row['total1']?></span></td>                                                                
                                <td><span><?php echo $row['asiste1_cal']?></span></td>                                                                
                                <td><span><?php echo $row['total2']?></span></td>                                                                
                                <td><span><?php echo $row['asiste2_cal']?></span></td>
                                <td><span><?php echo ($row['total2']+$row['total1'])?></span></td>
                                <td><span><?php echo round(($row['asiste1_cal']+$row['asiste2_cal'])/2)?></span></td>
                                <td><span><?php if($row["estado_cur"]==2){ echo 'APROBADO';}else if($row["estado_cur"]==3){echo 'REPROBADO';} ?></span></td>
                                <td><p><?php echo $row['obsevaFinal']?></p></td>

                            </tr>

                            <?php
                            $cont++;
                        }
                        ?>
                    </tbody>
                </table>        
                <?php
            }
            ?>
        </form>
    </div>
    
</div>
